package com.wdh.kjs.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ScrollView;

import com.wdh.kjs.Adapter.FM_financerecord_Adapter;
import com.wdh.kjs.Adapter.FM_raising_Adapter;
import com.wdh.kjs.Adapter.ListViewForScrollView;
import com.wdh.kjs.Adapter.UF_per_p_Adapter;
import com.wdh.kjs.R;
import com.wdh.kjs.activity.UploadFile_Per_1_Activity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * Created by dingh on 2016/4/3.
 */
public class UF_per_1_Fragment extends Fragment {
    private ListViewForScrollView listView;
    private UF_per_p_Adapter UploadFile_Per_1;
    private ScrollView scrollView;
    public int QUERY_TYPE=0;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.upload_file_scrollview, container, false);
        initView(view);
        loadData();
        return view;
    }
    private void initView(View view) {
        scrollView=(ScrollView)view.findViewById(R.id.upload_file_scrollview);
        scrollView.smoothScrollTo(0, 0);
        listView=(ListViewForScrollView)view.findViewById(R.id.upload_file_listview);
    }
    private void loadData()
    {
        switch (QUERY_TYPE)
        {
            case 0:
                UploadFile_Per_1=new UF_per_p_Adapter(getContext(),initListViewData());
                listView.setAdapter(UploadFile_Per_1);
                break;
            case 1:
                UploadFile_Per_1=new UF_per_p_Adapter(getContext(),initListViewData());
                listView.setAdapter(UploadFile_Per_1);
                break;
            case 2:
                UploadFile_Per_1=new UF_per_p_Adapter(getContext(),initListViewData());
                listView.setAdapter(UploadFile_Per_1);
                break;

        }

    }
    private List<HashMap<String, String>> initListViewData()
    {
        List<HashMap<String, String>> datas=new ArrayList<>();
        switch (QUERY_TYPE)
        {
            case 0:
                for(int i=0;i<2;i++){
                    HashMap<String, String> hashMap = new HashMap<>();
                    hashMap.put("fileName", "文件名1.docx");
                    hashMap.put("fileSize", "1.2M");
                    datas.add(hashMap);
                }
                for(int i=0;i<2;i++){
                    HashMap<String,String> hashMap =new HashMap<>();
                    hashMap.put("fileName","文件名2.xlsx");
                    hashMap.put("fileSize", "123k");
                    datas.add(hashMap);
                }
                break;
            case 1:
                for(int i=0;i<3;i++){
                    HashMap<String, String> hashMap = new HashMap<>();
                    hashMap.put("fileName", "文件名1.docx");
                    hashMap.put("fileSize", "1.2M");
                    datas.add(hashMap);
                }
                break;
            case 2:
                for(int i=0;i<2;i++){
                    HashMap<String,String> hashMap =new HashMap<>();
                    hashMap.put("fileName","文件名2.xlsx");
                    hashMap.put("fileSize", "123k");
                    datas.add(hashMap);
                }
                break;
        }

        return datas;
    }


}
